local que_qisheng = fk.CreateSkill {
    name = "que_qisheng",
    anim_type = "defensive",
    tags = { Skill.Compulsory },
}
Fk:loadTranslationTable {
    ["que_qisheng"] = "奇胜",
    [":que_qisheng"] = "锁定技，结束阶段，若“国士”等于13，你移去所有“国士”，增加一点体力上限回复一点体力，摸5张牌，本局游戏你使用牌无次数和距离限制；" ..
        "若你累计发动两次该技能，任意阶段结束时，你获胜。",

    ["$que_qisheng1"] = " ",
    ["$que_qisheng2"] = " ",
}
que_qisheng:addEffect(fk.EventPhaseStart, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(que_qisheng.name) and #player:getPile("fuji_guoshi") == 13 and
            player.phase == Player.Finish
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local cardIds = player:getPile("fuji_guoshi")
        room:moveCards({
            from = player,
            ids = cardIds,
            toArea = Card.DiscardPile,
            moveReason = fk.ReasonPutIntoDiscardPile,
            skillName = que_qisheng.name,
        })
        player:drawCards(5, que_qisheng.name)
        room:setPlayerMark(player, "@fuji_guo", 0)
        room:changeMaxHp(player, 1)
        room:recover({
            who = player,
            num = 1,
            recoverBy = player,
            skillName = que_qisheng.name
        })
    end,
})

que_qisheng:addEffect(fk.EventPhaseEnd, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(que_qisheng.name) and
            player:usedSkillTimes(que_qisheng.name, Player.HistoryGame) > 1
      end,
      on_use = function(self, event, target, player, data)
        local room = player.room
        player:broadcastSkillInvoke("que_qisheng", 3)
        room:delay(2000)
        room:gameOver(player.role)
      end,
})

que_qisheng:addEffect("targetmod", {
    bypass_distances = function(self, player, skill, card)
        return card and player:hasSkill(que_qisheng.name) and
            player:usedSkillTimes(que_qisheng.name, Player.HistoryGame) > 0
    end,
    bypass_times = function(self, player, skill, scope, card, to)
        return player:hasSkill(que_qisheng.name) and scope == Player.HistoryPhase and
            player:usedSkillTimes(que_qisheng.name, Player.HistoryGame) > 0
    end,
})
return que_qisheng
